#include <REGX52.H>
#include <string.h>
#include <stdio.h>
#define CongRaX P1
#define CongRaY P2
#define CongRaZ P0

int vitriX,vitriY,vitriZ;
unsigned char MaBuoc[4] ={0x00,0x01,0x02,0x04};
void delay()
{
	int i;
	for(i=0;i<100;i++);
}

void iniRS232()
{		
	TMOD = 0x20;
	TH1=0xfd;
	SCON =0x50;
	TR1=1;
	TI=1;
}


void quay(int moix,int moiy,int moiz)
{
	while(moix!=vitriX ||moiy!=vitriY ||moiz!=vitriZ)
	{
		if(moix<vitriX)
			{					
				vitriX--;
				CongRaX = vitriX%4;
			}
		if(moiy<vitriY)
			 {
			 	vitriY--;
				CongRaY = vitriY%4;
			 }
		if(moiz<vitriZ)
		{
			vitriZ--;
			CongRaZ = vitriZ%4;
		}

		if(moix>vitriX)
		{
			vitriX++;
			CongRaX = vitriX%4;
		}
		if(moiy>vitriY)
		{
			vitriY++;
			CongRaY = vitriY%4;
		}
		if(moiz>vitriZ)
		{
			vitriZ++;
			CongRaZ = vitriZ%4;
		}
		delay();		
	}
}

void main()
{			  
	char str;	
	unsigned int x,y,z;
	iniRS232();
		
	while(1)
	{	
		x = 0;
		y = 0;
		z = 0;						
		while(str!='(' )
		{
			str=_getkey();			
		}
		while(str!=',')
		{
			str=_getkey();			
			if(str!=',')
				x = x*10+(str-0x30);
		}
		str=0x00;
		while(str!=',')
		{
			str=_getkey();			
			if(str!=',')
				y = y*10+(str-0x30);
		}		
		while(str!=')')
		{
			str=_getkey();			
			if(str!=')')
				z = z*10+(
				str-0x30);
		}		
		//quay(x,y,z);		
		delay();
		printf("d");
	}
}
